#!/bin/bash
#
# vdsm-store-net-config: store network configuration files persistently
#
# this should be used ONLY in ovirt.

NET_CONF_DIR='/etc/sysconfig/network-scripts/'
NET_CONF_BACK_DIR=${NET_CONF_DIR}.vdsmback
DELETE_HEADER='# original file did not exist'

if rpm -q --qf '' ovirt-node;
then
    . /usr/libexec/ovirt-functions

    for f in "$NET_CONF_BACK_DIR"/*;
    do
        [ ! -f "$f" ] && continue
        bf=`basename "$f"`
        if [ -f "$NET_CONF_DIR/$bf" ];
        then
            ovirt_store_config "$NET_CONF_DIR/$bf"
        else
            ovirt_safe_delete_config "$NET_CONF_DIR/$bf"
        fi
        rm "$NET_CONF_BACK_DIR/$bf"
    done
else
    rm -rf "$NET_CONF_BACK_DIR"/*
fi
